import XCTest
@testable import ZMSwiftUtils


final class ZMSwiftUtilsTests: XCTestCase {
    
    func testSwizzle() {
        let swizzleObject = SwizzleTest()
        swizzleObject.execute()
        XCTAssert(swizzleObject.swizzle)
    }
}

extension ZMSwiftUtilsTests {
    
    func testRoute() {
        "kpath://reader/123/chapterId/12345/markId/4/pageId/adad?a=1&b=2".openRoute()
        "kpath://book/1234".openRoute()
    }
}


extension ZMSwiftUtilsTests {
    
    func testUUID() {
        XCTAssert(UUIDUtils.getUDID().length > 0)
    }
}

extension ZMSwiftUtilsTests {
    
    public class func testHandler() {
        
        enum EventType: String, HandlerEventType {
            case test
        }
        
        let eventBus = HandlerEventBus<EventType>()
        
        eventBus.register(type: .test) { data in
            guard let type = data as? EventType else {
                return
            }
            XCTAssertEqual(type, EventType.test)
        }
        eventBus.trigger(type: .test, data: EventType.test)
    }
}
